/// @tags: GeneralSuffixAutoMaton
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

namespace BlueQuantum {

typedef long long LL;

constexpr int MAXN = 2e5 + 3, SAMN = MAXN * 4, CHARSET = 26;

int samcnt = 1;
int link[SAMN], len[SAMN], siz[SAMN][2], ch[SAMN][CHARSET];
char str[MAXN];
vector<int> G[SAMN];

inline int insert(int c, int lst, int id) {
  if (ch[lst][c]) {
    int p = lst, q = ch[p][c];
    if (len[p] + 1 == len[q]) {
      siz[q][id] = 1;
      return q;
    } else {
      int nq = ++samcnt;
      len[nq] = len[p] + 1;
      for (int i = 0; i < 26; ++i) ch[nq][i] = ch[q][i];
      while (p && ch[p][c] == q) ch[p][c] = nq, p = link[p];
      link[nq] = link[q], link[q] = nq;
      siz[nq][id] = 1;
      return nq;
    }
  }
  int np = ++samcnt, p = lst;
  len[np] = len[lst] + 1;
  while (p && ch[p][c] == 0) ch[p][c] = np, p = link[p];
  if (!p)
    link[np] = 1;
  else {
    int q = ch[p][c];
    if (len[p] + 1 == len[q])
      link[np] = q;
    else {
      int nq = ++samcnt;
      len[nq] = len[p] + 1;
      memcpy(ch[nq], ch[q], sizeof(ch[nq]));
      link[nq] = link[q], link[np] = link[q] = nq;
      while (p && ch[p][c] == q) ch[p][c] = nq, p = link[p];
    }
  }
  siz[np][id] = 1;
  return np;
}

LL dfs(int u) {
  LL res = 0;
  for (auto v : G[u]) {
    res += dfs(v);
    siz[u][0] += siz[v][0];
    siz[u][1] += siz[v][1];
  }
  return res += (LL)siz[u][0] * siz[u][1] * (len[u] - len[link[u]]);
}

inline int main() {
  for (int i = 0; i < 2; ++i) {
    cin >> (str + 1);
    int lst = 1;
    for (int j = 1; str[j]; ++j) lst = insert(str[j] - 'a', lst, i);
  }
  for (int i = 2; i <= samcnt; ++i) G[link[i]].push_back(i);
  cout << dfs(1) << '\n';
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3181 [HAOI2016] 找相同字符.in", "r", stdin);
  freopen("P3181 [HAOI2016] 找相同字符.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
